github.com/expr-lang/expr@v1.16.9/vm/runtime/helpers[generated].go (about) 1 // Code generated by vm/runtime/helpers/main.go. DO NOT EDIT. 2 3 package runtime 4 5 import ( 6 "fmt" 7 "reflect" 8 "time" 9 ) 10 11 func Equal(a, b interface{}) bool { 12 switch x := a.(type) { 13 case uint: 14 switch y := b.(type) { 15 case uint: 16 return int(x) == int(y) 17 case uint8: 18 return int(x) == int(y) 19 case uint16: 20 return int(x) == int(y) 21 case uint32: 22 return int(x) == int(y) 23 case uint64: 24 return int(x) == int(y) 25 case int: 26 return int(x) == int(y) 27 case int8: 28 return int(x) == int(y) 29 case int16: 30 return int(x) == int(y) 31 case int32: 32 return int(x) == int(y) 33 case int64: 34 return int(x) == int(y) 35 case float32: 36 return float64(x) == float64(y) 37 case float64: 38 return float64(x) == float64(y) 39 } 40 case uint8: 41 switch y := b.(type) { 42 case uint: 43 return int(x) == int(y) 44 case uint8: 45 return int(x) == int(y) 46 case uint16: 47 return int(x) == int(y) 48 case uint32: 49 return int(x) == int(y) 50 case uint64: 51 return int(x) == int(y) 52 case int: 53 return int(x) == int(y) 54 case int8: 55 return int(x) == int(y) 56 case int16: 57 return int(x) == int(y) 58 case int32: 59 return int(x) == int(y) 60 case int64: 61 return int(x) == int(y) 62 case float32: 63 return float64(x) == float64(y) 64 case float64: 65 return float64(x) == float64(y) 66 } 67 case uint16: 68 switch y := b.(type) { 69 case uint: 70 return int(x) == int(y) 71 case uint8: 72 return int(x) == int(y) 73 case uint16: 74 return int(x) == int(y) 75 case uint32: 76 return int(x) == int(y) 77 case uint64: 78 return int(x) == int(y) 79 case int: 80 return int(x) == int(y) 81 case int8: 82 return int(x) == int(y) 83 case int16: 84 return int(x) == int(y) 85 case int32: 86 return int(x) == int(y) 87 case int64: 88 return int(x) == int(y) 89 case float32: 90 return float64(x) == float64(y) 91 case float64: 92 return float64(x) == float64(y) 93 } 94 case uint32: 95 switch y := b.(type) { 96 case uint: 97 return int(x) == int(y) 98 case uint8: 99 return int(x) == int(y) 100 case uint16: 101 return int(x) == int(y) 102 case uint32: 103 return int(x) == int(y) 104 case uint64: 105 return int(x) == int(y) 106 case int: 107 return int(x) == int(y) 108 case int8: 109 return int(x) == int(y) 110 case int16: 111 return int(x) == int(y) 112 case int32: 113 return int(x) == int(y) 114 case int64: 115 return int(x) == int(y) 116 case float32: 117 return float64(x) == float64(y) 118 case float64: 119 return float64(x) == float64(y) 120 } 121 case uint64: 122 switch y := b.(type) { 123 case uint: 124 return int(x) == int(y) 125 case uint8: 126 return int(x) == int(y) 127 case uint16: 128 return int(x) == int(y) 129 case uint32: 130 return int(x) == int(y) 131 case uint64: 132 return int(x) == int(y) 133 case int: 134 return int(x) == int(y) 135 case int8: 136 return int(x) == int(y) 137 case int16: 138 return int(x) == int(y) 139 case int32: 140 return int(x) == int(y) 141 case int64: 142 return int(x) == int(y) 143 case float32: 144 return float64(x) == float64(y) 145 case float64: 146 return float64(x) == float64(y) 147 } 148 case int: 149 switch y := b.(type) { 150 case uint: 151 return int(x) == int(y) 152 case uint8: 153 return int(x) == int(y) 154 case uint16: 155 return int(x) == int(y) 156 case uint32: 157 return int(x) == int(y) 158 case uint64: 159 return int(x) == int(y) 160 case int: 161 return int(x) == int(y) 162 case int8: 163 return int(x) == int(y) 164 case int16: 165 return int(x) == int(y) 166 case int32: 167 return int(x) == int(y) 168 case int64: 169 return int(x) == int(y) 170 case float32: 171 return float64(x) == float64(y) 172 case float64: 173 return float64(x) == float64(y) 174 } 175 case int8: 176 switch y := b.(type) { 177 case uint: 178 return int(x) == int(y) 179 case uint8: 180 return int(x) == int(y) 181 case uint16: 182 return int(x) == int(y) 183 case uint32: 184 return int(x) == int(y) 185 case uint64: 186 return int(x) == int(y) 187 case int: 188 return int(x) == int(y) 189 case int8: 190 return int(x) == int(y) 191 case int16: 192 return int(x) == int(y) 193 case int32: 194 return int(x) == int(y) 195 case int64: 196 return int(x) == int(y) 197 case float32: 198 return float64(x) == float64(y) 199 case float64: 200 return float64(x) == float64(y) 201 } 202 case int16: 203 switch y := b.(type) { 204 case uint: 205 return int(x) == int(y) 206 case uint8: 207 return int(x) == int(y) 208 case uint16: 209 return int(x) == int(y) 210 case uint32: 211 return int(x) == int(y) 212 case uint64: 213 return int(x) == int(y) 214 case int: 215 return int(x) == int(y) 216 case int8: 217 return int(x) == int(y) 218 case int16: 219 return int(x) == int(y) 220 case int32: 221 return int(x) == int(y) 222 case int64: 223 return int(x) == int(y) 224 case float32: 225 return float64(x) == float64(y) 226 case float64: 227 return float64(x) == float64(y) 228 } 229 case int32: 230 switch y := b.(type) { 231 case uint: 232 return int(x) == int(y) 233 case uint8: 234 return int(x) == int(y) 235 case uint16: 236 return int(x) == int(y) 237 case uint32: 238 return int(x) == int(y) 239 case uint64: 240 return int(x) == int(y) 241 case int: 242 return int(x) == int(y) 243 case int8: 244 return int(x) == int(y) 245 case int16: 246 return int(x) == int(y) 247 case int32: 248 return int(x) == int(y) 249 case int64: 250 return int(x) == int(y) 251 case float32: 252 return float64(x) == float64(y) 253 case float64: 254 return float64(x) == float64(y) 255 } 256 case int64: 257 switch y := b.(type) { 258 case uint: 259 return int(x) == int(y) 260 case uint8: 261 return int(x) == int(y) 262 case uint16: 263 return int(x) == int(y) 264 case uint32: 265 return int(x) == int(y) 266 case uint64: 267 return int(x) == int(y) 268 case int: 269 return int(x) == int(y) 270 case int8: 271 return int(x) == int(y) 272 case int16: 273 return int(x) == int(y) 274 case int32: 275 return int(x) == int(y) 276 case int64: 277 return int(x) == int(y) 278 case float32: 279 return float64(x) == float64(y) 280 case float64: 281 return float64(x) == float64(y) 282 } 283 case float32: 284 switch y := b.(type) { 285 case uint: 286 return float64(x) == float64(y) 287 case uint8: 288 return float64(x) == float64(y) 289 case uint16: 290 return float64(x) == float64(y) 291 case uint32: 292 return float64(x) == float64(y) 293 case uint64: 294 return float64(x) == float64(y) 295 case int: 296 return float64(x) == float64(y) 297 case int8: 298 return float64(x) == float64(y) 299 case int16: 300 return float64(x) == float64(y) 301 case int32: 302 return float64(x) == float64(y) 303 case int64: 304 return float64(x) == float64(y) 305 case float32: 306 return float64(x) == float64(y) 307 case float64: 308 return float64(x) == float64(y) 309 } 310 case float64: 311 switch y := b.(type) { 312 case uint: 313 return float64(x) == float64(y) 314 case uint8: 315 return float64(x) == float64(y) 316 case uint16: 317 return float64(x) == float64(y) 318 case uint32: 319 return float64(x) == float64(y) 320 case uint64: 321 return float64(x) == float64(y) 322 case int: 323 return float64(x) == float64(y) 324 case int8: 325 return float64(x) == float64(y) 326 case int16: 327 return float64(x) == float64(y) 328 case int32: 329 return float64(x) == float64(y) 330 case int64: 331 return float64(x) == float64(y) 332 case float32: 333 return float64(x) == float64(y) 334 case float64: 335 return float64(x) == float64(y) 336 } 337 case []any: 338 switch y := b.(type) { 339 case []string: 340 if len(x) != len(y) { 341 return false 342 } 343 for i := range x { 344 if !Equal(x[i], y[i]) { 345 return false 346 } 347 } 348 return true 349 case []uint: 350 if len(x) != len(y) { 351 return false 352 } 353 for i := range x { 354 if !Equal(x[i], y[i]) { 355 return false 356 } 357 } 358 return true 359 case []uint8: 360 if len(x) != len(y) { 361 return false 362 } 363 for i := range x { 364 if !Equal(x[i], y[i]) { 365 return false 366 } 367 } 368 return true 369 case []uint16: 370 if len(x) != len(y) { 371 return false 372 } 373 for i := range x { 374 if !Equal(x[i], y[i]) { 375 return false 376 } 377 } 378 return true 379 case []uint32: 380 if len(x) != len(y) { 381 return false 382 } 383 for i := range x { 384 if !Equal(x[i], y[i]) { 385 return false 386 } 387 } 388 return true 389 case []uint64: 390 if len(x) != len(y) { 391 return false 392 } 393 for i := range x { 394 if !Equal(x[i], y[i]) { 395 return false 396 } 397 } 398 return true 399 case []int: 400 if len(x) != len(y) { 401 return false 402 } 403 for i := range x { 404 if !Equal(x[i], y[i]) { 405 return false 406 } 407 } 408 return true 409 case []int8: 410 if len(x) != len(y) { 411 return false 412 } 413 for i := range x { 414 if !Equal(x[i], y[i]) { 415 return false 416 } 417 } 418 return true 419 case []int16: 420 if len(x) != len(y) { 421 return false 422 } 423 for i := range x { 424 if !Equal(x[i], y[i]) { 425 return false 426 } 427 } 428 return true 429 case []int32: 430 if len(x) != len(y) { 431 return false 432 } 433 for i := range x { 434 if !Equal(x[i], y[i]) { 435 return false 436 } 437 } 438 return true 439 case []int64: 440 if len(x) != len(y) { 441 return false 442 } 443 for i := range x { 444 if !Equal(x[i], y[i]) { 445 return false 446 } 447 } 448 return true 449 case []float32: 450 if len(x) != len(y) { 451 return false 452 } 453 for i := range x { 454 if !Equal(x[i], y[i]) { 455 return false 456 } 457 } 458 return true 459 case []float64: 460 if len(x) != len(y) { 461 return false 462 } 463 for i := range x { 464 if !Equal(x[i], y[i]) { 465 return false 466 } 467 } 468 return true 469 case []any: 470 if len(x) != len(y) { 471 return false 472 } 473 for i := range x { 474 if !Equal(x[i], y[i]) { 475 return false 476 } 477 } 478 return true 479 } 480 case []string: 481 switch y := b.(type) { 482 case []any: 483 return Equal(y, x) 484 case []string: 485 if len(x) != len(y) { 486 return false 487 } 488 for i := range x { 489 if x[i] != y[i] { 490 return false 491 } 492 } 493 return true 494 } 495 case []uint: 496 switch y := b.(type) { 497 case []any: 498 return Equal(y, x) 499 case []uint: 500 if len(x) != len(y) { 501 return false 502 } 503 for i := range x { 504 if x[i] != y[i] { 505 return false 506 } 507 } 508 return true 509 } 510 case []uint8: 511 switch y := b.(type) { 512 case []any: 513 return Equal(y, x) 514 case []uint8: 515 if len(x) != len(y) { 516 return false 517 } 518 for i := range x { 519 if x[i] != y[i] { 520 return false 521 } 522 } 523 return true 524 } 525 case []uint16: 526 switch y := b.(type) { 527 case []any: 528 return Equal(y, x) 529 case []uint16: 530 if len(x) != len(y) { 531 return false 532 } 533 for i := range x { 534 if x[i] != y[i] { 535 return false 536 } 537 } 538 return true 539 } 540 case []uint32: 541 switch y := b.(type) { 542 case []any: 543 return Equal(y, x) 544 case []uint32: 545 if len(x) != len(y) { 546 return false 547 } 548 for i := range x { 549 if x[i] != y[i] { 550 return false 551 } 552 } 553 return true 554 } 555 case []uint64: 556 switch y := b.(type) { 557 case []any: 558 return Equal(y, x) 559 case []uint64: 560 if len(x) != len(y) { 561 return false 562 } 563 for i := range x { 564 if x[i] != y[i] { 565 return false 566 } 567 } 568 return true 569 } 570 case []int: 571 switch y := b.(type) { 572 case []any: 573 return Equal(y, x) 574 case []int: 575 if len(x) != len(y) { 576 return false 577 } 578 for i := range x { 579 if x[i] != y[i] { 580 return false 581 } 582 } 583 return true 584 } 585 case []int8: 586 switch y := b.(type) { 587 case []any: 588 return Equal(y, x) 589 case []int8: 590 if len(x) != len(y) { 591 return false 592 } 593 for i := range x { 594 if x[i] != y[i] { 595 return false 596 } 597 } 598 return true 599 } 600 case []int16: 601 switch y := b.(type) { 602 case []any: 603 return Equal(y, x) 604 case []int16: 605 if len(x) != len(y) { 606 return false 607 } 608 for i := range x { 609 if x[i] != y[i] { 610 return false 611 } 612 } 613 return true 614 } 615 case []int32: 616 switch y := b.(type) { 617 case []any: 618 return Equal(y, x) 619 case []int32: 620 if len(x) != len(y) { 621 return false 622 } 623 for i := range x { 624 if x[i] != y[i] { 625 return false 626 } 627 } 628 return true 629 } 630 case []int64: 631 switch y := b.(type) { 632 case []any: 633 return Equal(y, x) 634 case []int64: 635 if len(x) != len(y) { 636 return false 637 } 638 for i := range x { 639 if x[i] != y[i] { 640 return false 641 } 642 } 643 return true 644 } 645 case []float32: 646 switch y := b.(type) { 647 case []any: 648 return Equal(y, x) 649 case []float32: 650 if len(x) != len(y) { 651 return false 652 } 653 for i := range x { 654 if x[i] != y[i] { 655 return false 656 } 657 } 658 return true 659 } 660 case []float64: 661 switch y := b.(type) { 662 case []any: 663 return Equal(y, x) 664 case []float64: 665 if len(x) != len(y) { 666 return false 667 } 668 for i := range x { 669 if x[i] != y[i] { 670 return false 671 } 672 } 673 return true 674 } 675 case string: 676 switch y := b.(type) { 677 case string: 678 return x == y 679 } 680 case time.Time: 681 switch y := b.(type) { 682 case time.Time: 683 return x.Equal(y) 684 } 685 case time.Duration: 686 switch y := b.(type) { 687 case time.Duration: 688 return x == y 689 } 690 case bool: 691 switch y := b.(type) { 692 case bool: 693 return x == y 694 } 695 } 696 if IsNil(a) && IsNil(b) { 697 return true 698 } 699 return reflect.DeepEqual(a, b) 700 } 701 702 func Less(a, b interface{}) bool { 703 switch x := a.(type) { 704 case uint: 705 switch y := b.(type) { 706 case uint: 707 return int(x) < int(y) 708 case uint8: 709 return int(x) < int(y) 710 case uint16: 711 return int(x) < int(y) 712 case uint32: 713 return int(x) < int(y) 714 case uint64: 715 return int(x) < int(y) 716 case int: 717 return int(x) < int(y) 718 case int8: 719 return int(x) < int(y) 720 case int16: 721 return int(x) < int(y) 722 case int32: 723 return int(x) < int(y) 724 case int64: 725 return int(x) < int(y) 726 case float32: 727 return float64(x) < float64(y) 728 case float64: 729 return float64(x) < float64(y) 730 } 731 case uint8: 732 switch y := b.(type) { 733 case uint: 734 return int(x) < int(y) 735 case uint8: 736 return int(x) < int(y) 737 case uint16: 738 return int(x) < int(y) 739 case uint32: 740 return int(x) < int(y) 741 case uint64: 742 return int(x) < int(y) 743 case int: 744 return int(x) < int(y) 745 case int8: 746 return int(x) < int(y) 747 case int16: 748 return int(x) < int(y) 749 case int32: 750 return int(x) < int(y) 751 case int64: 752 return int(x) < int(y) 753 case float32: 754 return float64(x) < float64(y) 755 case float64: 756 return float64(x) < float64(y) 757 } 758 case uint16: 759 switch y := b.(type) { 760 case uint: 761 return int(x) < int(y) 762 case uint8: 763 return int(x) < int(y) 764 case uint16: 765 return int(x) < int(y) 766 case uint32: 767 return int(x) < int(y) 768 case uint64: 769 return int(x) < int(y) 770 case int: 771 return int(x) < int(y) 772 case int8: 773 return int(x) < int(y) 774 case int16: 775 return int(x) < int(y) 776 case int32: 777 return int(x) < int(y) 778 case int64: 779 return int(x) < int(y) 780 case float32: 781 return float64(x) < float64(y) 782 case float64: 783 return float64(x) < float64(y) 784 } 785 case uint32: 786 switch y := b.(type) { 787 case uint: 788 return int(x) < int(y) 789 case uint8: 790 return int(x) < int(y) 791 case uint16: 792 return int(x) < int(y) 793 case uint32: 794 return int(x) < int(y) 795 case uint64: 796 return int(x) < int(y) 797 case int: 798 return int(x) < int(y) 799 case int8: 800 return int(x) < int(y) 801 case int16: 802 return int(x) < int(y) 803 case int32: 804 return int(x) < int(y) 805 case int64: 806 return int(x) < int(y) 807 case float32: 808 return float64(x) < float64(y) 809 case float64: 810 return float64(x) < float64(y) 811 } 812 case uint64: 813 switch y := b.(type) { 814 case uint: 815 return int(x) < int(y) 816 case uint8: 817 return int(x) < int(y) 818 case uint16: 819 return int(x) < int(y) 820 case uint32: 821 return int(x) < int(y) 822 case uint64: 823 return int(x) < int(y) 824 case int: 825 return int(x) < int(y) 826 case int8: 827 return int(x) < int(y) 828 case int16: 829 return int(x) < int(y) 830 case int32: 831 return int(x) < int(y) 832 case int64: 833 return int(x) < int(y) 834 case float32: 835 return float64(x) < float64(y) 836 case float64: 837 return float64(x) < float64(y) 838 } 839 case int: 840 switch y := b.(type) { 841 case uint: 842 return int(x) < int(y) 843 case uint8: 844 return int(x) < int(y) 845 case uint16: 846 return int(x) < int(y) 847 case uint32: 848 return int(x) < int(y) 849 case uint64: 850 return int(x) < int(y) 851 case int: 852 return int(x) < int(y) 853 case int8: 854 return int(x) < int(y) 855 case int16: 856 return int(x) < int(y) 857 case int32: 858 return int(x) < int(y) 859 case int64: 860 return int(x) < int(y) 861 case float32: 862 return float64(x) < float64(y) 863 case float64: 864 return float64(x) < float64(y) 865 } 866 case int8: 867 switch y := b.(type) { 868 case uint: 869 return int(x) < int(y) 870 case uint8: 871 return int(x) < int(y) 872 case uint16: 873 return int(x) < int(y) 874 case uint32: 875 return int(x) < int(y) 876 case uint64: 877 return int(x) < int(y) 878 case int: 879 return int(x) < int(y) 880 case int8: 881 return int(x) < int(y) 882 case int16: 883 return int(x) < int(y) 884 case int32: 885 return int(x) < int(y) 886 case int64: 887 return int(x) < int(y) 888 case float32: 889 return float64(x) < float64(y) 890 case float64: 891 return float64(x) < float64(y) 892 } 893 case int16: 894 switch y := b.(type) { 895 case uint: 896 return int(x) < int(y) 897 case uint8: 898 return int(x) < int(y) 899 case uint16: 900 return int(x) < int(y) 901 case uint32: 902 return int(x) < int(y) 903 case uint64: 904 return int(x) < int(y) 905 case int: 906 return int(x) < int(y) 907 case int8: 908 return int(x) < int(y) 909 case int16: 910 return int(x) < int(y) 911 case int32: 912 return int(x) < int(y) 913 case int64: 914 return int(x) < int(y) 915 case float32: 916 return float64(x) < float64(y) 917 case float64: 918 return float64(x) < float64(y) 919 } 920 case int32: 921 switch y := b.(type) { 922 case uint: 923 return int(x) < int(y) 924 case uint8: 925 return int(x) < int(y) 926 case uint16: 927 return int(x) < int(y) 928 case uint32: 929 return int(x) < int(y) 930 case uint64: 931 return int(x) < int(y) 932 case int: 933 return int(x) < int(y) 934 case int8: 935 return int(x) < int(y) 936 case int16: 937 return int(x) < int(y) 938 case int32: 939 return int(x) < int(y) 940 case int64: 941 return int(x) < int(y) 942 case float32: 943 return float64(x) < float64(y) 944 case float64: 945 return float64(x) < float64(y) 946 } 947 case int64: 948 switch y := b.(type) { 949 case uint: 950 return int(x) < int(y) 951 case uint8: 952 return int(x) < int(y) 953 case uint16: 954 return int(x) < int(y) 955 case uint32: 956 return int(x) < int(y) 957 case uint64: 958 return int(x) < int(y) 959 case int: 960 return int(x) < int(y) 961 case int8: 962 return int(x) < int(y) 963 case int16: 964 return int(x) < int(y) 965 case int32: 966 return int(x) < int(y) 967 case int64: 968 return int(x) < int(y) 969 case float32: 970 return float64(x) < float64(y) 971 case float64: 972 return float64(x) < float64(y) 973 } 974 case float32: 975 switch y := b.(type) { 976 case uint: 977 return float64(x) < float64(y) 978 case uint8: 979 return float64(x) < float64(y) 980 case uint16: 981 return float64(x) < float64(y) 982 case uint32: 983 return float64(x) < float64(y) 984 case uint64: 985 return float64(x) < float64(y) 986 case int: 987 return float64(x) < float64(y) 988 case int8: 989 return float64(x) < float64(y) 990 case int16: 991 return float64(x) < float64(y) 992 case int32: 993 return float64(x) < float64(y) 994 case int64: 995 return float64(x) < float64(y) 996 case float32: 997 return float64(x) < float64(y) 998 case float64: 999 return float64(x) < float64(y) 1000 } 1001 case float64: 1002 switch y := b.(type) { 1003 case uint: 1004 return float64(x) < float64(y) 1005 case uint8: 1006 return float64(x) < float64(y) 1007 case uint16: 1008 return float64(x) < float64(y) 1009 case uint32: 1010 return float64(x) < float64(y) 1011 case uint64: 1012 return float64(x) < float64(y) 1013 case int: 1014 return float64(x) < float64(y) 1015 case int8: 1016 return float64(x) < float64(y) 1017 case int16: 1018 return float64(x) < float64(y) 1019 case int32: 1020 return float64(x) < float64(y) 1021 case int64: 1022 return float64(x) < float64(y) 1023 case float32: 1024 return float64(x) < float64(y) 1025 case float64: 1026 return float64(x) < float64(y) 1027 } 1028 case string: 1029 switch y := b.(type) { 1030 case string: 1031 return x < y 1032 } 1033 case time.Time: 1034 switch y := b.(type) { 1035 case time.Time: 1036 return x.Before(y) 1037 } 1038 case time.Duration: 1039 switch y := b.(type) { 1040 case time.Duration: 1041 return x < y 1042 } 1043 } 1044 panic(fmt.Sprintf("invalid operation: %T < %T", a, b)) 1045 } 1046 1047 func More(a, b interface{}) bool { 1048 switch x := a.(type) { 1049 case uint: 1050 switch y := b.(type) { 1051 case uint: 1052 return int(x) > int(y) 1053 case uint8: 1054 return int(x) > int(y) 1055 case uint16: 1056 return int(x) > int(y) 1057 case uint32: 1058 return int(x) > int(y) 1059 case uint64: 1060 return int(x) > int(y) 1061 case int: 1062 return int(x) > int(y) 1063 case int8: 1064 return int(x) > int(y) 1065 case int16: 1066 return int(x) > int(y) 1067 case int32: 1068 return int(x) > int(y) 1069 case int64: 1070 return int(x) > int(y) 1071 case float32: 1072 return float64(x) > float64(y) 1073 case float64: 1074 return float64(x) > float64(y) 1075 } 1076 case uint8: 1077 switch y := b.(type) { 1078 case uint: 1079 return int(x) > int(y) 1080 case uint8: 1081 return int(x) > int(y) 1082 case uint16: 1083 return int(x) > int(y) 1084 case uint32: 1085 return int(x) > int(y) 1086 case uint64: 1087 return int(x) > int(y) 1088 case int: 1089 return int(x) > int(y) 1090 case int8: 1091 return int(x) > int(y) 1092 case int16: 1093 return int(x) > int(y) 1094 case int32: 1095 return int(x) > int(y) 1096 case int64: 1097 return int(x) > int(y) 1098 case float32: 1099 return float64(x) > float64(y) 1100 case float64: 1101 return float64(x) > float64(y) 1102 } 1103 case uint16: 1104 switch y := b.(type) { 1105 case uint: 1106 return int(x) > int(y) 1107 case uint8: 1108 return int(x) > int(y) 1109 case uint16: 1110 return int(x) > int(y) 1111 case uint32: 1112 return int(x) > int(y) 1113 case uint64: 1114 return int(x) > int(y) 1115 case int: 1116 return int(x) > int(y) 1117 case int8: 1118 return int(x) > int(y) 1119 case int16: 1120 return int(x) > int(y) 1121 case int32: 1122 return int(x) > int(y) 1123 case int64: 1124 return int(x) > int(y) 1125 case float32: 1126 return float64(x) > float64(y) 1127 case float64: 1128 return float64(x) > float64(y) 1129 } 1130 case uint32: 1131 switch y := b.(type) { 1132 case uint: 1133 return int(x) > int(y) 1134 case uint8: 1135 return int(x) > int(y) 1136 case uint16: 1137 return int(x) > int(y) 1138 case uint32: 1139 return int(x) > int(y) 1140 case uint64: 1141 return int(x) > int(y) 1142 case int: 1143 return int(x) > int(y) 1144 case int8: 1145 return int(x) > int(y) 1146 case int16: 1147 return int(x) > int(y) 1148 case int32: 1149 return int(x) > int(y) 1150 case int64: 1151 return int(x) > int(y) 1152 case float32: 1153 return float64(x) > float64(y) 1154 case float64: 1155 return float64(x) > float64(y) 1156 } 1157 case uint64: 1158 switch y := b.(type) { 1159 case uint: 1160 return int(x) > int(y) 1161 case uint8: 1162 return int(x) > int(y) 1163 case uint16: 1164 return int(x) > int(y) 1165 case uint32: 1166 return int(x) > int(y) 1167 case uint64: 1168 return int(x) > int(y) 1169 case int: 1170 return int(x) > int(y) 1171 case int8: 1172 return int(x) > int(y) 1173 case int16: 1174 return int(x) > int(y) 1175 case int32: 1176 return int(x) > int(y) 1177 case int64: 1178 return int(x) > int(y) 1179 case float32: 1180 return float64(x) > float64(y) 1181 case float64: 1182 return float64(x) > float64(y) 1183 } 1184 case int: 1185 switch y := b.(type) { 1186 case uint: 1187 return int(x) > int(y) 1188 case uint8: 1189 return int(x) > int(y) 1190 case uint16: 1191 return int(x) > int(y) 1192 case uint32: 1193 return int(x) > int(y) 1194 case uint64: 1195 return int(x) > int(y) 1196 case int: 1197 return int(x) > int(y) 1198 case int8: 1199 return int(x) > int(y) 1200 case int16: 1201 return int(x) > int(y) 1202 case int32: 1203 return int(x) > int(y) 1204 case int64: 1205 return int(x) > int(y) 1206 case float32: 1207 return float64(x) > float64(y) 1208 case float64: 1209 return float64(x) > float64(y) 1210 } 1211 case int8: 1212 switch y := b.(type) { 1213 case uint: 1214 return int(x) > int(y) 1215 case uint8: 1216 return int(x) > int(y) 1217 case uint16: 1218 return int(x) > int(y) 1219 case uint32: 1220 return int(x) > int(y) 1221 case uint64: 1222 return int(x) > int(y) 1223 case int: 1224 return int(x) > int(y) 1225 case int8: 1226 return int(x) > int(y) 1227 case int16: 1228 return int(x) > int(y) 1229 case int32: 1230 return int(x) > int(y) 1231 case int64: 1232 return int(x) > int(y) 1233 case float32: 1234 return float64(x) > float64(y) 1235 case float64: 1236 return float64(x) > float64(y) 1237 } 1238 case int16: 1239 switch y := b.(type) { 1240 case uint: 1241 return int(x) > int(y) 1242 case uint8: 1243 return int(x) > int(y) 1244 case uint16: 1245 return int(x) > int(y) 1246 case uint32: 1247 return int(x) > int(y) 1248 case uint64: 1249 return int(x) > int(y) 1250 case int: 1251 return int(x) > int(y) 1252 case int8: 1253 return int(x) > int(y) 1254 case int16: 1255 return int(x) > int(y) 1256 case int32: 1257 return int(x) > int(y) 1258 case int64: 1259 return int(x) > int(y) 1260 case float32: 1261 return float64(x) > float64(y) 1262 case float64: 1263 return float64(x) > float64(y) 1264 } 1265 case int32: 1266 switch y := b.(type) { 1267 case uint: 1268 return int(x) > int(y) 1269 case uint8: 1270 return int(x) > int(y) 1271 case uint16: 1272 return int(x) > int(y) 1273 case uint32: 1274 return int(x) > int(y) 1275 case uint64: 1276 return int(x) > int(y) 1277 case int: 1278 return int(x) > int(y) 1279 case int8: 1280 return int(x) > int(y) 1281 case int16: 1282 return int(x) > int(y) 1283 case int32: 1284 return int(x) > int(y) 1285 case int64: 1286 return int(x) > int(y) 1287 case float32: 1288 return float64(x) > float64(y) 1289 case float64: 1290 return float64(x) > float64(y) 1291 } 1292 case int64: 1293 switch y := b.(type) { 1294 case uint: 1295 return int(x) > int(y) 1296 case uint8: 1297 return int(x) > int(y) 1298 case uint16: 1299 return int(x) > int(y) 1300 case uint32: 1301 return int(x) > int(y) 1302 case uint64: 1303 return int(x) > int(y) 1304 case int: 1305 return int(x) > int(y) 1306 case int8: 1307 return int(x) > int(y) 1308 case int16: 1309 return int(x) > int(y) 1310 case int32: 1311 return int(x) > int(y) 1312 case int64: 1313 return int(x) > int(y) 1314 case float32: 1315 return float64(x) > float64(y) 1316 case float64: 1317 return float64(x) > float64(y) 1318 } 1319 case float32: 1320 switch y := b.(type) { 1321 case uint: 1322 return float64(x) > float64(y) 1323 case uint8: 1324 return float64(x) > float64(y) 1325 case uint16: 1326 return float64(x) > float64(y) 1327 case uint32: 1328 return float64(x) > float64(y) 1329 case uint64: 1330 return float64(x) > float64(y) 1331 case int: 1332 return float64(x) > float64(y) 1333 case int8: 1334 return float64(x) > float64(y) 1335 case int16: 1336 return float64(x) > float64(y) 1337 case int32: 1338 return float64(x) > float64(y) 1339 case int64: 1340 return float64(x) > float64(y) 1341 case float32: 1342 return float64(x) > float64(y) 1343 case float64: 1344 return float64(x) > float64(y) 1345 } 1346 case float64: 1347 switch y := b.(type) { 1348 case uint: 1349 return float64(x) > float64(y) 1350 case uint8: 1351 return float64(x) > float64(y) 1352 case uint16: 1353 return float64(x) > float64(y) 1354 case uint32: 1355 return float64(x) > float64(y) 1356 case uint64: 1357 return float64(x) > float64(y) 1358 case int: 1359 return float64(x) > float64(y) 1360 case int8: 1361 return float64(x) > float64(y) 1362 case int16: 1363 return float64(x) > float64(y) 1364 case int32: 1365 return float64(x) > float64(y) 1366 case int64: 1367 return float64(x) > float64(y) 1368 case float32: 1369 return float64(x) > float64(y) 1370 case float64: 1371 return float64(x) > float64(y) 1372 } 1373 case string: 1374 switch y := b.(type) { 1375 case string: 1376 return x > y 1377 } 1378 case time.Time: 1379 switch y := b.(type) { 1380 case time.Time: 1381 return x.After(y) 1382 } 1383 case time.Duration: 1384 switch y := b.(type) { 1385 case time.Duration: 1386 return x > y 1387 } 1388 } 1389 panic(fmt.Sprintf("invalid operation: %T > %T", a, b)) 1390 } 1391 1392 func LessOrEqual(a, b interface{}) bool { 1393 switch x := a.(type) { 1394 case uint: 1395 switch y := b.(type) { 1396 case uint: 1397 return int(x) <= int(y) 1398 case uint8: 1399 return int(x) <= int(y) 1400 case uint16: 1401 return int(x) <= int(y) 1402 case uint32: 1403 return int(x) <= int(y) 1404 case uint64: 1405 return int(x) <= int(y) 1406 case int: 1407 return int(x) <= int(y) 1408 case int8: 1409 return int(x) <= int(y) 1410 case int16: 1411 return int(x) <= int(y) 1412 case int32: 1413 return int(x) <= int(y) 1414 case int64: 1415 return int(x) <= int(y) 1416 case float32: 1417 return float64(x) <= float64(y) 1418 case float64: 1419 return float64(x) <= float64(y) 1420 } 1421 case uint8: 1422 switch y := b.(type) { 1423 case uint: 1424 return int(x) <= int(y) 1425 case uint8: 1426 return int(x) <= int(y) 1427 case uint16: 1428 return int(x) <= int(y) 1429 case uint32: 1430 return int(x) <= int(y) 1431 case uint64: 1432 return int(x) <= int(y) 1433 case int: 1434 return int(x) <= int(y) 1435 case int8: 1436 return int(x) <= int(y) 1437 case int16: 1438 return int(x) <= int(y) 1439 case int32: 1440 return int(x) <= int(y) 1441 case int64: 1442 return int(x) <= int(y) 1443 case float32: 1444 return float64(x) <= float64(y) 1445 case float64: 1446 return float64(x) <= float64(y) 1447 } 1448 case uint16: 1449 switch y := b.(type) { 1450 case uint: 1451 return int(x) <= int(y) 1452 case uint8: 1453 return int(x) <= int(y) 1454 case uint16: 1455 return int(x) <= int(y) 1456 case uint32: 1457 return int(x) <= int(y) 1458 case uint64: 1459 return int(x) <= int(y) 1460 case int: 1461 return int(x) <= int(y) 1462 case int8: 1463 return int(x) <= int(y) 1464 case int16: 1465 return int(x) <= int(y) 1466 case int32: 1467 return int(x) <= int(y) 1468 case int64: 1469 return int(x) <= int(y) 1470 case float32: 1471 return float64(x) <= float64(y) 1472 case float64: 1473 return float64(x) <= float64(y) 1474 } 1475 case uint32: 1476 switch y := b.(type) { 1477 case uint: 1478 return int(x) <= int(y) 1479 case uint8: 1480 return int(x) <= int(y) 1481 case uint16: 1482 return int(x) <= int(y) 1483 case uint32: 1484 return int(x) <= int(y) 1485 case uint64: 1486 return int(x) <= int(y) 1487 case int: 1488 return int(x) <= int(y) 1489 case int8: 1490 return int(x) <= int(y) 1491 case int16: 1492 return int(x) <= int(y) 1493 case int32: 1494 return int(x) <= int(y) 1495 case int64: 1496 return int(x) <= int(y) 1497 case float32: 1498 return float64(x) <= float64(y) 1499 case float64: 1500 return float64(x) <= float64(y) 1501 } 1502 case uint64: 1503 switch y := b.(type) { 1504 case uint: 1505 return int(x) <= int(y) 1506 case uint8: 1507 return int(x) <= int(y) 1508 case uint16: 1509 return int(x) <= int(y) 1510 case uint32: 1511 return int(x) <= int(y) 1512 case uint64: 1513 return int(x) <= int(y) 1514 case int: 1515 return int(x) <= int(y) 1516 case int8: 1517 return int(x) <= int(y) 1518 case int16: 1519 return int(x) <= int(y) 1520 case int32: 1521 return int(x) <= int(y) 1522 case int64: 1523 return int(x) <= int(y) 1524 case float32: 1525 return float64(x) <= float64(y) 1526 case float64: 1527 return float64(x) <= float64(y) 1528 } 1529 case int: 1530 switch y := b.(type) { 1531 case uint: 1532 return int(x) <= int(y) 1533 case uint8: 1534 return int(x) <= int(y) 1535 case uint16: 1536 return int(x) <= int(y) 1537 case uint32: 1538 return int(x) <= int(y) 1539 case uint64: 1540 return int(x) <= int(y) 1541 case int: 1542 return int(x) <= int(y) 1543 case int8: 1544 return int(x) <= int(y) 1545 case int16: 1546 return int(x) <= int(y) 1547 case int32: 1548 return int(x) <= int(y) 1549 case int64: 1550 return int(x) <= int(y) 1551 case float32: 1552 return float64(x) <= float64(y) 1553 case float64: 1554 return float64(x) <= float64(y) 1555 } 1556 case int8: 1557 switch y := b.(type) { 1558 case uint: 1559 return int(x) <= int(y) 1560 case uint8: 1561 return int(x) <= int(y) 1562 case uint16: 1563 return int(x) <= int(y) 1564 case uint32: 1565 return int(x) <= int(y) 1566 case uint64: 1567 return int(x) <= int(y) 1568 case int: 1569 return int(x) <= int(y) 1570 case int8: 1571 return int(x) <= int(y) 1572 case int16: 1573 return int(x) <= int(y) 1574 case int32: 1575 return int(x) <= int(y) 1576 case int64: 1577 return int(x) <= int(y) 1578 case float32: 1579 return float64(x) <= float64(y) 1580 case float64: 1581 return float64(x) <= float64(y) 1582 } 1583 case int16: 1584 switch y := b.(type) { 1585 case uint: 1586 return int(x) <= int(y) 1587 case uint8: 1588 return int(x) <= int(y) 1589 case uint16: 1590 return int(x) <= int(y) 1591 case uint32: 1592 return int(x) <= int(y) 1593 case uint64: 1594 return int(x) <= int(y) 1595 case int: 1596 return int(x) <= int(y) 1597 case int8: 1598 return int(x) <= int(y) 1599 case int16: 1600 return int(x) <= int(y) 1601 case int32: 1602 return int(x) <= int(y) 1603 case int64: 1604 return int(x) <= int(y) 1605 case float32: 1606 return float64(x) <= float64(y) 1607 case float64: 1608 return float64(x) <= float64(y) 1609 } 1610 case int32: 1611 switch y := b.(type) { 1612 case uint: 1613 return int(x) <= int(y) 1614 case uint8: 1615 return int(x) <= int(y) 1616 case uint16: 1617 return int(x) <= int(y) 1618 case uint32: 1619 return int(x) <= int(y) 1620 case uint64: 1621 return int(x) <= int(y) 1622 case int: 1623 return int(x) <= int(y) 1624 case int8: 1625 return int(x) <= int(y) 1626 case int16: 1627 return int(x) <= int(y) 1628 case int32: 1629 return int(x) <= int(y) 1630 case int64: 1631 return int(x) <= int(y) 1632 case float32: 1633 return float64(x) <= float64(y) 1634 case float64: 1635 return float64(x) <= float64(y) 1636 } 1637 case int64: 1638 switch y := b.(type) { 1639 case uint: 1640 return int(x) <= int(y) 1641 case uint8: 1642 return int(x) <= int(y) 1643 case uint16: 1644 return int(x) <= int(y) 1645 case uint32: 1646 return int(x) <= int(y) 1647 case uint64: 1648 return int(x) <= int(y) 1649 case int: 1650 return int(x) <= int(y) 1651 case int8: 1652 return int(x) <= int(y) 1653 case int16: 1654 return int(x) <= int(y) 1655 case int32: 1656 return int(x) <= int(y) 1657 case int64: 1658 return int(x) <= int(y) 1659 case float32: 1660 return float64(x) <= float64(y) 1661 case float64: 1662 return float64(x) <= float64(y) 1663 } 1664 case float32: 1665 switch y := b.(type) { 1666 case uint: 1667 return float64(x) <= float64(y) 1668 case uint8: 1669 return float64(x) <= float64(y) 1670 case uint16: 1671 return float64(x) <= float64(y) 1672 case uint32: 1673 return float64(x) <= float64(y) 1674 case uint64: 1675 return float64(x) <= float64(y) 1676 case int: 1677 return float64(x) <= float64(y) 1678 case int8: 1679 return float64(x) <= float64(y) 1680 case int16: 1681 return float64(x) <= float64(y) 1682 case int32: 1683 return float64(x) <= float64(y) 1684 case int64: 1685 return float64(x) <= float64(y) 1686 case float32: 1687 return float64(x) <= float64(y) 1688 case float64: 1689 return float64(x) <= float64(y) 1690 } 1691 case float64: 1692 switch y := b.(type) { 1693 case uint: 1694 return float64(x) <= float64(y) 1695 case uint8: 1696 return float64(x) <= float64(y) 1697 case uint16: 1698 return float64(x) <= float64(y) 1699 case uint32: 1700 return float64(x) <= float64(y) 1701 case uint64: 1702 return float64(x) <= float64(y) 1703 case int: 1704 return float64(x) <= float64(y) 1705 case int8: 1706 return float64(x) <= float64(y) 1707 case int16: 1708 return float64(x) <= float64(y) 1709 case int32: 1710 return float64(x) <= float64(y) 1711 case int64: 1712 return float64(x) <= float64(y) 1713 case float32: 1714 return float64(x) <= float64(y) 1715 case float64: 1716 return float64(x) <= float64(y) 1717 } 1718 case string: 1719 switch y := b.(type) { 1720 case string: 1721 return x <= y 1722 } 1723 case time.Time: 1724 switch y := b.(type) { 1725 case time.Time: 1726 return x.Before(y) || x.Equal(y) 1727 } 1728 case time.Duration: 1729 switch y := b.(type) { 1730 case time.Duration: 1731 return x <= y 1732 } 1733 } 1734 panic(fmt.Sprintf("invalid operation: %T <= %T", a, b)) 1735 } 1736 1737 func MoreOrEqual(a, b interface{}) bool { 1738 switch x := a.(type) { 1739 case uint: 1740 switch y := b.(type) { 1741 case uint: 1742 return int(x) >= int(y) 1743 case uint8: 1744 return int(x) >= int(y) 1745 case uint16: 1746 return int(x) >= int(y) 1747 case uint32: 1748 return int(x) >= int(y) 1749 case uint64: 1750 return int(x) >= int(y) 1751 case int: 1752 return int(x) >= int(y) 1753 case int8: 1754 return int(x) >= int(y) 1755 case int16: 1756 return int(x) >= int(y) 1757 case int32: 1758 return int(x) >= int(y) 1759 case int64: 1760 return int(x) >= int(y) 1761 case float32: 1762 return float64(x) >= float64(y) 1763 case float64: 1764 return float64(x) >= float64(y) 1765 } 1766 case uint8: 1767 switch y := b.(type) { 1768 case uint: 1769 return int(x) >= int(y) 1770 case uint8: 1771 return int(x) >= int(y) 1772 case uint16: 1773 return int(x) >= int(y) 1774 case uint32: 1775 return int(x) >= int(y) 1776 case uint64: 1777 return int(x) >= int(y) 1778 case int: 1779 return int(x) >= int(y) 1780 case int8: 1781 return int(x) >= int(y) 1782 case int16: 1783 return int(x) >= int(y) 1784 case int32: 1785 return int(x) >= int(y) 1786 case int64: 1787 return int(x) >= int(y) 1788 case float32: 1789 return float64(x) >= float64(y) 1790 case float64: 1791 return float64(x) >= float64(y) 1792 } 1793 case uint16: 1794 switch y := b.(type) { 1795 case uint: 1796 return int(x) >= int(y) 1797 case uint8: 1798 return int(x) >= int(y) 1799 case uint16: 1800 return int(x) >= int(y) 1801 case uint32: 1802 return int(x) >= int(y) 1803 case uint64: 1804 return int(x) >= int(y) 1805 case int: 1806 return int(x) >= int(y) 1807 case int8: 1808 return int(x) >= int(y) 1809 case int16: 1810 return int(x) >= int(y) 1811 case int32: 1812 return int(x) >= int(y) 1813 case int64: 1814 return int(x) >= int(y) 1815 case float32: 1816 return float64(x) >= float64(y) 1817 case float64: 1818 return float64(x) >= float64(y) 1819 } 1820 case uint32: 1821 switch y := b.(type) { 1822 case uint: 1823 return int(x) >= int(y) 1824 case uint8: 1825 return int(x) >= int(y) 1826 case uint16: 1827 return int(x) >= int(y) 1828 case uint32: 1829 return int(x) >= int(y) 1830 case uint64: 1831 return int(x) >= int(y) 1832 case int: 1833 return int(x) >= int(y) 1834 case int8: 1835 return int(x) >= int(y) 1836 case int16: 1837 return int(x) >= int(y) 1838 case int32: 1839 return int(x) >= int(y) 1840 case int64: 1841 return int(x) >= int(y) 1842 case float32: 1843 return float64(x) >= float64(y) 1844 case float64: 1845 return float64(x) >= float64(y) 1846 } 1847 case uint64: 1848 switch y := b.(type) { 1849 case uint: 1850 return int(x) >= int(y) 1851 case uint8: 1852 return int(x) >= int(y) 1853 case uint16: 1854 return int(x) >= int(y) 1855 case uint32: 1856 return int(x) >= int(y) 1857 case uint64: 1858 return int(x) >= int(y) 1859 case int: 1860 return int(x) >= int(y) 1861 case int8: 1862 return int(x) >= int(y) 1863 case int16: 1864 return int(x) >= int(y) 1865 case int32: 1866 return int(x) >= int(y) 1867 case int64: 1868 return int(x) >= int(y) 1869 case float32: 1870 return float64(x) >= float64(y) 1871 case float64: 1872 return float64(x) >= float64(y) 1873 } 1874 case int: 1875 switch y := b.(type) { 1876 case uint: 1877 return int(x) >= int(y) 1878 case uint8: 1879 return int(x) >= int(y) 1880 case uint16: 1881 return int(x) >= int(y) 1882 case uint32: 1883 return int(x) >= int(y) 1884 case uint64: 1885 return int(x) >= int(y) 1886 case int: 1887 return int(x) >= int(y) 1888 case int8: 1889 return int(x) >= int(y) 1890 case int16: 1891 return int(x) >= int(y) 1892 case int32: 1893 return int(x) >= int(y) 1894 case int64: 1895 return int(x) >= int(y) 1896 case float32: 1897 return float64(x) >= float64(y) 1898 case float64: 1899 return float64(x) >= float64(y) 1900 } 1901 case int8: 1902 switch y := b.(type) { 1903 case uint: 1904 return int(x) >= int(y) 1905 case uint8: 1906 return int(x) >= int(y) 1907 case uint16: 1908 return int(x) >= int(y) 1909 case uint32: 1910 return int(x) >= int(y) 1911 case uint64: 1912 return int(x) >= int(y) 1913 case int: 1914 return int(x) >= int(y) 1915 case int8: 1916 return int(x) >= int(y) 1917 case int16: 1918 return int(x) >= int(y) 1919 case int32: 1920 return int(x) >= int(y) 1921 case int64: 1922 return int(x) >= int(y) 1923 case float32: 1924 return float64(x) >= float64(y) 1925 case float64: 1926 return float64(x) >= float64(y) 1927 } 1928 case int16: 1929 switch y := b.(type) { 1930 case uint: 1931 return int(x) >= int(y) 1932 case uint8: 1933 return int(x) >= int(y) 1934 case uint16: 1935 return int(x) >= int(y) 1936 case uint32: 1937 return int(x) >= int(y) 1938 case uint64: 1939 return int(x) >= int(y) 1940 case int: 1941 return int(x) >= int(y) 1942 case int8: 1943 return int(x) >= int(y) 1944 case int16: 1945 return int(x) >= int(y) 1946 case int32: 1947 return int(x) >= int(y) 1948 case int64: 1949 return int(x) >= int(y) 1950 case float32: 1951 return float64(x) >= float64(y) 1952 case float64: 1953 return float64(x) >= float64(y) 1954 } 1955 case int32: 1956 switch y := b.(type) { 1957 case uint: 1958 return int(x) >= int(y) 1959 case uint8: 1960 return int(x) >= int(y) 1961 case uint16: 1962 return int(x) >= int(y) 1963 case uint32: 1964 return int(x) >= int(y) 1965 case uint64: 1966 return int(x) >= int(y) 1967 case int: 1968 return int(x) >= int(y) 1969 case int8: 1970 return int(x) >= int(y) 1971 case int16: 1972 return int(x) >= int(y) 1973 case int32: 1974 return int(x) >= int(y) 1975 case int64: 1976 return int(x) >= int(y) 1977 case float32: 1978 return float64(x) >= float64(y) 1979 case float64: 1980 return float64(x) >= float64(y) 1981 } 1982 case int64: 1983 switch y := b.(type) { 1984 case uint: 1985 return int(x) >= int(y) 1986 case uint8: 1987 return int(x) >= int(y) 1988 case uint16: 1989 return int(x) >= int(y) 1990 case uint32: 1991 return int(x) >= int(y) 1992 case uint64: 1993 return int(x) >= int(y) 1994 case int: 1995 return int(x) >= int(y) 1996 case int8: 1997 return int(x) >= int(y) 1998 case int16: 1999 return int(x) >= int(y) 2000 case int32: 2001 return int(x) >= int(y) 2002 case int64: 2003 return int(x) >= int(y) 2004 case float32: 2005 return float64(x) >= float64(y) 2006 case float64: 2007 return float64(x) >= float64(y) 2008 } 2009 case float32: 2010 switch y := b.(type) { 2011 case uint: 2012 return float64(x) >= float64(y) 2013 case uint8: 2014 return float64(x) >= float64(y) 2015 case uint16: 2016 return float64(x) >= float64(y) 2017 case uint32: 2018 return float64(x) >= float64(y) 2019 case uint64: 2020 return float64(x) >= float64(y) 2021 case int: 2022 return float64(x) >= float64(y) 2023 case int8: 2024 return float64(x) >= float64(y) 2025 case int16: 2026 return float64(x) >= float64(y) 2027 case int32: 2028 return float64(x) >= float64(y) 2029 case int64: 2030 return float64(x) >= float64(y) 2031 case float32: 2032 return float64(x) >= float64(y) 2033 case float64: 2034 return float64(x) >= float64(y) 2035 } 2036 case float64: 2037 switch y := b.(type) { 2038 case uint: 2039 return float64(x) >= float64(y) 2040 case uint8: 2041 return float64(x) >= float64(y) 2042 case uint16: 2043 return float64(x) >= float64(y) 2044 case uint32: 2045 return float64(x) >= float64(y) 2046 case uint64: 2047 return float64(x) >= float64(y) 2048 case int: 2049 return float64(x) >= float64(y) 2050 case int8: 2051 return float64(x) >= float64(y) 2052 case int16: 2053 return float64(x) >= float64(y) 2054 case int32: 2055 return float64(x) >= float64(y) 2056 case int64: 2057 return float64(x) >= float64(y) 2058 case float32: 2059 return float64(x) >= float64(y) 2060 case float64: 2061 return float64(x) >= float64(y) 2062 } 2063 case string: 2064 switch y := b.(type) { 2065 case string: 2066 return x >= y 2067 } 2068 case time.Time: 2069 switch y := b.(type) { 2070 case time.Time: 2071 return x.After(y) || x.Equal(y) 2072 } 2073 case time.Duration: 2074 switch y := b.(type) { 2075 case time.Duration: 2076 return x >= y 2077 } 2078 } 2079 panic(fmt.Sprintf("invalid operation: %T >= %T", a, b)) 2080 } 2081 2082 func Add(a, b interface{}) interface{} { 2083 switch x := a.(type) { 2084 case uint: 2085 switch y := b.(type) { 2086 case uint: 2087 return int(x) + int(y) 2088 case uint8: 2089 return int(x) + int(y) 2090 case uint16: 2091 return int(x) + int(y) 2092 case uint32: 2093 return int(x) + int(y) 2094 case uint64: 2095 return int(x) + int(y) 2096 case int: 2097 return int(x) + int(y) 2098 case int8: 2099 return int(x) + int(y) 2100 case int16: 2101 return int(x) + int(y) 2102 case int32: 2103 return int(x) + int(y) 2104 case int64: 2105 return int(x) + int(y) 2106 case float32: 2107 return float64(x) + float64(y) 2108 case float64: 2109 return float64(x) + float64(y) 2110 } 2111 case uint8: 2112 switch y := b.(type) { 2113 case uint: 2114 return int(x) + int(y) 2115 case uint8: 2116 return int(x) + int(y) 2117 case uint16: 2118 return int(x) + int(y) 2119 case uint32: 2120 return int(x) + int(y) 2121 case uint64: 2122 return int(x) + int(y) 2123 case int: 2124 return int(x) + int(y) 2125 case int8: 2126 return int(x) + int(y) 2127 case int16: 2128 return int(x) + int(y) 2129 case int32: 2130 return int(x) + int(y) 2131 case int64: 2132 return int(x) + int(y) 2133 case float32: 2134 return float64(x) + float64(y) 2135 case float64: 2136 return float64(x) + float64(y) 2137 } 2138 case uint16: 2139 switch y := b.(type) { 2140 case uint: 2141 return int(x) + int(y) 2142 case uint8: 2143 return int(x) + int(y) 2144 case uint16: 2145 return int(x) + int(y) 2146 case uint32: 2147 return int(x) + int(y) 2148 case uint64: 2149 return int(x) + int(y) 2150 case int: 2151 return int(x) + int(y) 2152 case int8: 2153 return int(x) + int(y) 2154 case int16: 2155 return int(x) + int(y) 2156 case int32: 2157 return int(x) + int(y) 2158 case int64: 2159 return int(x) + int(y) 2160 case float32: 2161 return float64(x) + float64(y) 2162 case float64: 2163 return float64(x) + float64(y) 2164 } 2165 case uint32: 2166 switch y := b.(type) { 2167 case uint: 2168 return int(x) + int(y) 2169 case uint8: 2170 return int(x) + int(y) 2171 case uint16: 2172 return int(x) + int(y) 2173 case uint32: 2174 return int(x) + int(y) 2175 case uint64: 2176 return int(x) + int(y) 2177 case int: 2178 return int(x) + int(y) 2179 case int8: 2180 return int(x) + int(y) 2181 case int16: 2182 return int(x) + int(y) 2183 case int32: 2184 return int(x) + int(y) 2185 case int64: 2186 return int(x) + int(y) 2187 case float32: 2188 return float64(x) + float64(y) 2189 case float64: 2190 return float64(x) + float64(y) 2191 } 2192 case uint64: 2193 switch y := b.(type) { 2194 case uint: 2195 return int(x) + int(y) 2196 case uint8: 2197 return int(x) + int(y) 2198 case uint16: 2199 return int(x) + int(y) 2200 case uint32: 2201 return int(x) + int(y) 2202 case uint64: 2203 return int(x) + int(y) 2204 case int: 2205 return int(x) + int(y) 2206 case int8: 2207 return int(x) + int(y) 2208 case int16: 2209 return int(x) + int(y) 2210 case int32: 2211 return int(x) + int(y) 2212 case int64: 2213 return int(x) + int(y) 2214 case float32: 2215 return float64(x) + float64(y) 2216 case float64: 2217 return float64(x) + float64(y) 2218 } 2219 case int: 2220 switch y := b.(type) { 2221 case uint: 2222 return int(x) + int(y) 2223 case uint8: 2224 return int(x) + int(y) 2225 case uint16: 2226 return int(x) + int(y) 2227 case uint32: 2228 return int(x) + int(y) 2229 case uint64: 2230 return int(x) + int(y) 2231 case int: 2232 return int(x) + int(y) 2233 case int8: 2234 return int(x) + int(y) 2235 case int16: 2236 return int(x) + int(y) 2237 case int32: 2238 return int(x) + int(y) 2239 case int64: 2240 return int(x) + int(y) 2241 case float32: 2242 return float64(x) + float64(y) 2243 case float64: 2244 return float64(x) + float64(y) 2245 } 2246 case int8: 2247 switch y := b.(type) { 2248 case uint: 2249 return int(x) + int(y) 2250 case uint8: 2251 return int(x) + int(y) 2252 case uint16: 2253 return int(x) + int(y) 2254 case uint32: 2255 return int(x) + int(y) 2256 case uint64: 2257 return int(x) + int(y) 2258 case int: 2259 return int(x) + int(y) 2260 case int8: 2261 return int(x) + int(y) 2262 case int16: 2263 return int(x) + int(y) 2264 case int32: 2265 return int(x) + int(y) 2266 case int64: 2267 return int(x) + int(y) 2268 case float32: 2269 return float64(x) + float64(y) 2270 case float64: 2271 return float64(x) + float64(y) 2272 } 2273 case int16: 2274 switch y := b.(type) { 2275 case uint: 2276 return int(x) + int(y) 2277 case uint8: 2278 return int(x) + int(y) 2279 case uint16: 2280 return int(x) + int(y) 2281 case uint32: 2282 return int(x) + int(y) 2283 case uint64: 2284 return int(x) + int(y) 2285 case int: 2286 return int(x) + int(y) 2287 case int8: 2288 return int(x) + int(y) 2289 case int16: 2290 return int(x) + int(y) 2291 case int32: 2292 return int(x) + int(y) 2293 case int64: 2294 return int(x) + int(y) 2295 case float32: 2296 return float64(x) + float64(y) 2297 case float64: 2298 return float64(x) + float64(y) 2299 } 2300 case int32: 2301 switch y := b.(type) { 2302 case uint: 2303 return int(x) + int(y) 2304 case uint8: 2305 return int(x) + int(y) 2306 case uint16: 2307 return int(x) + int(y) 2308 case uint32: 2309 return int(x) + int(y) 2310 case uint64: 2311 return int(x) + int(y) 2312 case int: 2313 return int(x) + int(y) 2314 case int8: 2315 return int(x) + int(y) 2316 case int16: 2317 return int(x) + int(y) 2318 case int32: 2319 return int(x) + int(y) 2320 case int64: 2321 return int(x) + int(y) 2322 case float32: 2323 return float64(x) + float64(y) 2324 case float64: 2325 return float64(x) + float64(y) 2326 } 2327 case int64: 2328 switch y := b.(type) { 2329 case uint: 2330 return int(x) + int(y) 2331 case uint8: 2332 return int(x) + int(y) 2333 case uint16: 2334 return int(x) + int(y) 2335 case uint32: 2336 return int(x) + int(y) 2337 case uint64: 2338 return int(x) + int(y) 2339 case int: 2340 return int(x) + int(y) 2341 case int8: 2342 return int(x) + int(y) 2343 case int16: 2344 return int(x) + int(y) 2345 case int32: 2346 return int(x) + int(y) 2347 case int64: 2348 return int(x) + int(y) 2349 case float32: 2350 return float64(x) + float64(y) 2351 case float64: 2352 return float64(x) + float64(y) 2353 } 2354 case float32: 2355 switch y := b.(type) { 2356 case uint: 2357 return float64(x) + float64(y) 2358 case uint8: 2359 return float64(x) + float64(y) 2360 case uint16: 2361 return float64(x) + float64(y) 2362 case uint32: 2363 return float64(x) + float64(y) 2364 case uint64: 2365 return float64(x) + float64(y) 2366 case int: 2367 return float64(x) + float64(y) 2368 case int8: 2369 return float64(x) + float64(y) 2370 case int16: 2371 return float64(x) + float64(y) 2372 case int32: 2373 return float64(x) + float64(y) 2374 case int64: 2375 return float64(x) + float64(y) 2376 case float32: 2377 return float64(x) + float64(y) 2378 case float64: 2379 return float64(x) + float64(y) 2380 } 2381 case float64: 2382 switch y := b.(type) { 2383 case uint: 2384 return float64(x) + float64(y) 2385 case uint8: 2386 return float64(x) + float64(y) 2387 case uint16: 2388 return float64(x) + float64(y) 2389 case uint32: 2390 return float64(x) + float64(y) 2391 case uint64: 2392 return float64(x) + float64(y) 2393 case int: 2394 return float64(x) + float64(y) 2395 case int8: 2396 return float64(x) + float64(y) 2397 case int16: 2398 return float64(x) + float64(y) 2399 case int32: 2400 return float64(x) + float64(y) 2401 case int64: 2402 return float64(x) + float64(y) 2403 case float32: 2404 return float64(x) + float64(y) 2405 case float64: 2406 return float64(x) + float64(y) 2407 } 2408 case string: 2409 switch y := b.(type) { 2410 case string: 2411 return x + y 2412 } 2413 case time.Time: 2414 switch y := b.(type) { 2415 case time.Duration: 2416 return x.Add(y) 2417 } 2418 case time.Duration: 2419 switch y := b.(type) { 2420 case time.Time: 2421 return y.Add(x) 2422 case time.Duration: 2423 return x + y 2424 } 2425 } 2426 panic(fmt.Sprintf("invalid operation: %T + %T", a, b)) 2427 } 2428 2429 func Subtract(a, b interface{}) interface{} { 2430 switch x := a.(type) { 2431 case uint: 2432 switch y := b.(type) { 2433 case uint: 2434 return int(x) - int(y) 2435 case uint8: 2436 return int(x) - int(y) 2437 case uint16: 2438 return int(x) - int(y) 2439 case uint32: 2440 return int(x) - int(y) 2441 case uint64: 2442 return int(x) - int(y) 2443 case int: 2444 return int(x) - int(y) 2445 case int8: 2446 return int(x) - int(y) 2447 case int16: 2448 return int(x) - int(y) 2449 case int32: 2450 return int(x) - int(y) 2451 case int64: 2452 return int(x) - int(y) 2453 case float32: 2454 return float64(x) - float64(y) 2455 case float64: 2456 return float64(x) - float64(y) 2457 } 2458 case uint8: 2459 switch y := b.(type) { 2460 case uint: 2461 return int(x) - int(y) 2462 case uint8: 2463 return int(x) - int(y) 2464 case uint16: 2465 return int(x) - int(y) 2466 case uint32: 2467 return int(x) - int(y) 2468 case uint64: 2469 return int(x) - int(y) 2470 case int: 2471 return int(x) - int(y) 2472 case int8: 2473 return int(x) - int(y) 2474 case int16: 2475 return int(x) - int(y) 2476 case int32: 2477 return int(x) - int(y) 2478 case int64: 2479 return int(x) - int(y) 2480 case float32: 2481 return float64(x) - float64(y) 2482 case float64: 2483 return float64(x) - float64(y) 2484 } 2485 case uint16: 2486 switch y := b.(type) { 2487 case uint: 2488 return int(x) - int(y) 2489 case uint8: 2490 return int(x) - int(y) 2491 case uint16: 2492 return int(x) - int(y) 2493 case uint32: 2494 return int(x) - int(y) 2495 case uint64: 2496 return int(x) - int(y) 2497 case int: 2498 return int(x) - int(y) 2499 case int8: 2500 return int(x) - int(y) 2501 case int16: 2502 return int(x) - int(y) 2503 case int32: 2504 return int(x) - int(y) 2505 case int64: 2506 return int(x) - int(y) 2507 case float32: 2508 return float64(x) - float64(y) 2509 case float64: 2510 return float64(x) - float64(y) 2511 } 2512 case uint32: 2513 switch y := b.(type) { 2514 case uint: 2515 return int(x) - int(y) 2516 case uint8: 2517 return int(x) - int(y) 2518 case uint16: 2519 return int(x) - int(y) 2520 case uint32: 2521 return int(x) - int(y) 2522 case uint64: 2523 return int(x) - int(y) 2524 case int: 2525 return int(x) - int(y) 2526 case int8: 2527 return int(x) - int(y) 2528 case int16: 2529 return int(x) - int(y) 2530 case int32: 2531 return int(x) - int(y) 2532 case int64: 2533 return int(x) - int(y) 2534 case float32: 2535 return float64(x) - float64(y) 2536 case float64: 2537 return float64(x) - float64(y) 2538 } 2539 case uint64: 2540 switch y := b.(type) { 2541 case uint: 2542 return int(x) - int(y) 2543 case uint8: 2544 return int(x) - int(y) 2545 case uint16: 2546 return int(x) - int(y) 2547 case uint32: 2548 return int(x) - int(y) 2549 case uint64: 2550 return int(x) - int(y) 2551 case int: 2552 return int(x) - int(y) 2553 case int8: 2554 return int(x) - int(y) 2555 case int16: 2556 return int(x) - int(y) 2557 case int32: 2558 return int(x) - int(y) 2559 case int64: 2560 return int(x) - int(y) 2561 case float32: 2562 return float64(x) - float64(y) 2563 case float64: 2564 return float64(x) - float64(y) 2565 } 2566 case int: 2567 switch y := b.(type) { 2568 case uint: 2569 return int(x) - int(y) 2570 case uint8: 2571 return int(x) - int(y) 2572 case uint16: 2573 return int(x) - int(y) 2574 case uint32: 2575 return int(x) - int(y) 2576 case uint64: 2577 return int(x) - int(y) 2578 case int: 2579 return int(x) - int(y) 2580 case int8: 2581 return int(x) - int(y) 2582 case int16: 2583 return int(x) - int(y) 2584 case int32: 2585 return int(x) - int(y) 2586 case int64: 2587 return int(x) - int(y) 2588 case float32: 2589 return float64(x) - float64(y) 2590 case float64: 2591 return float64(x) - float64(y) 2592 } 2593 case int8: 2594 switch y := b.(type) { 2595 case uint: 2596 return int(x) - int(y) 2597 case uint8: 2598 return int(x) - int(y) 2599 case uint16: 2600 return int(x) - int(y) 2601 case uint32: 2602 return int(x) - int(y) 2603 case uint64: 2604 return int(x) - int(y) 2605 case int: 2606 return int(x) - int(y) 2607 case int8: 2608 return int(x) - int(y) 2609 case int16: 2610 return int(x) - int(y) 2611 case int32: 2612 return int(x) - int(y) 2613 case int64: 2614 return int(x) - int(y) 2615 case float32: 2616 return float64(x) - float64(y) 2617 case float64: 2618 return float64(x) - float64(y) 2619 } 2620 case int16: 2621 switch y := b.(type) { 2622 case uint: 2623 return int(x) - int(y) 2624 case uint8: 2625 return int(x) - int(y) 2626 case uint16: 2627 return int(x) - int(y) 2628 case uint32: 2629 return int(x) - int(y) 2630 case uint64: 2631 return int(x) - int(y) 2632 case int: 2633 return int(x) - int(y) 2634 case int8: 2635 return int(x) - int(y) 2636 case int16: 2637 return int(x) - int(y) 2638 case int32: 2639 return int(x) - int(y) 2640 case int64: 2641 return int(x) - int(y) 2642 case float32: 2643 return float64(x) - float64(y) 2644 case float64: 2645 return float64(x) - float64(y) 2646 } 2647 case int32: 2648 switch y := b.(type) { 2649 case uint: 2650 return int(x) - int(y) 2651 case uint8: 2652 return int(x) - int(y) 2653 case uint16: 2654 return int(x) - int(y) 2655 case uint32: 2656 return int(x) - int(y) 2657 case uint64: 2658 return int(x) - int(y) 2659 case int: 2660 return int(x) - int(y) 2661 case int8: 2662 return int(x) - int(y) 2663 case int16: 2664 return int(x) - int(y) 2665 case int32: 2666 return int(x) - int(y) 2667 case int64: 2668 return int(x) - int(y) 2669 case float32: 2670 return float64(x) - float64(y) 2671 case float64: 2672 return float64(x) - float64(y) 2673 } 2674 case int64: 2675 switch y := b.(type) { 2676 case uint: 2677 return int(x) - int(y) 2678 case uint8: 2679 return int(x) - int(y) 2680 case uint16: 2681 return int(x) - int(y) 2682 case uint32: 2683 return int(x) - int(y) 2684 case uint64: 2685 return int(x) - int(y) 2686 case int: 2687 return int(x) - int(y) 2688 case int8: 2689 return int(x) - int(y) 2690 case int16: 2691 return int(x) - int(y) 2692 case int32: 2693 return int(x) - int(y) 2694 case int64: 2695 return int(x) - int(y) 2696 case float32: 2697 return float64(x) - float64(y) 2698 case float64: 2699 return float64(x) - float64(y) 2700 } 2701 case float32: 2702 switch y := b.(type) { 2703 case uint: 2704 return float64(x) - float64(y) 2705 case uint8: 2706 return float64(x) - float64(y) 2707 case uint16: 2708 return float64(x) - float64(y) 2709 case uint32: 2710 return float64(x) - float64(y) 2711 case uint64: 2712 return float64(x) - float64(y) 2713 case int: 2714 return float64(x) - float64(y) 2715 case int8: 2716 return float64(x) - float64(y) 2717 case int16: 2718 return float64(x) - float64(y) 2719 case int32: 2720 return float64(x) - float64(y) 2721 case int64: 2722 return float64(x) - float64(y) 2723 case float32: 2724 return float64(x) - float64(y) 2725 case float64: 2726 return float64(x) - float64(y) 2727 } 2728 case float64: 2729 switch y := b.(type) { 2730 case uint: 2731 return float64(x) - float64(y) 2732 case uint8: 2733 return float64(x) - float64(y) 2734 case uint16: 2735 return float64(x) - float64(y) 2736 case uint32: 2737 return float64(x) - float64(y) 2738 case uint64: 2739 return float64(x) - float64(y) 2740 case int: 2741 return float64(x) - float64(y) 2742 case int8: 2743 return float64(x) - float64(y) 2744 case int16: 2745 return float64(x) - float64(y) 2746 case int32: 2747 return float64(x) - float64(y) 2748 case int64: 2749 return float64(x) - float64(y) 2750 case float32: 2751 return float64(x) - float64(y) 2752 case float64: 2753 return float64(x) - float64(y) 2754 } 2755 case time.Time: 2756 switch y := b.(type) { 2757 case time.Time: 2758 return x.Sub(y) 2759 case time.Duration: 2760 return x.Add(-y) 2761 } 2762 case time.Duration: 2763 switch y := b.(type) { 2764 case time.Duration: 2765 return x - y 2766 } 2767 } 2768 panic(fmt.Sprintf("invalid operation: %T - %T", a, b)) 2769 } 2770 2771 func Multiply(a, b interface{}) interface{} { 2772 switch x := a.(type) { 2773 case uint: 2774 switch y := b.(type) { 2775 case uint: 2776 return int(x) * int(y) 2777 case uint8: 2778 return int(x) * int(y) 2779 case uint16: 2780 return int(x) * int(y) 2781 case uint32: 2782 return int(x) * int(y) 2783 case uint64: 2784 return int(x) * int(y) 2785 case int: 2786 return int(x) * int(y) 2787 case int8: 2788 return int(x) * int(y) 2789 case int16: 2790 return int(x) * int(y) 2791 case int32: 2792 return int(x) * int(y) 2793 case int64: 2794 return int(x) * int(y) 2795 case float32: 2796 return float64(x) * float64(y) 2797 case float64: 2798 return float64(x) * float64(y) 2799 case time.Duration: 2800 return time.Duration(x) * time.Duration(y) 2801 } 2802 case uint8: 2803 switch y := b.(type) { 2804 case uint: 2805 return int(x) * int(y) 2806 case uint8: 2807 return int(x) * int(y) 2808 case uint16: 2809 return int(x) * int(y) 2810 case uint32: 2811 return int(x) * int(y) 2812 case uint64: 2813 return int(x) * int(y) 2814 case int: 2815 return int(x) * int(y) 2816 case int8: 2817 return int(x) * int(y) 2818 case int16: 2819 return int(x) * int(y) 2820 case int32: 2821 return int(x) * int(y) 2822 case int64: 2823 return int(x) * int(y) 2824 case float32: 2825 return float64(x) * float64(y) 2826 case float64: 2827 return float64(x) * float64(y) 2828 case time.Duration: 2829 return time.Duration(x) * time.Duration(y) 2830 } 2831 case uint16: 2832 switch y := b.(type) { 2833 case uint: 2834 return int(x) * int(y) 2835 case uint8: 2836 return int(x) * int(y) 2837 case uint16: 2838 return int(x) * int(y) 2839 case uint32: 2840 return int(x) * int(y) 2841 case uint64: 2842 return int(x) * int(y) 2843 case int: 2844 return int(x) * int(y) 2845 case int8: 2846 return int(x) * int(y) 2847 case int16: 2848 return int(x) * int(y) 2849 case int32: 2850 return int(x) * int(y) 2851 case int64: 2852 return int(x) * int(y) 2853 case float32: 2854 return float64(x) * float64(y) 2855 case float64: 2856 return float64(x) * float64(y) 2857 case time.Duration: 2858 return time.Duration(x) * time.Duration(y) 2859 } 2860 case uint32: 2861 switch y := b.(type) { 2862 case uint: 2863 return int(x) * int(y) 2864 case uint8: 2865 return int(x) * int(y) 2866 case uint16: 2867 return int(x) * int(y) 2868 case uint32: 2869 return int(x) * int(y) 2870 case uint64: 2871 return int(x) * int(y) 2872 case int: 2873 return int(x) * int(y) 2874 case int8: 2875 return int(x) * int(y) 2876 case int16: 2877 return int(x) * int(y) 2878 case int32: 2879 return int(x) * int(y) 2880 case int64: 2881 return int(x) * int(y) 2882 case float32: 2883 return float64(x) * float64(y) 2884 case float64: 2885 return float64(x) * float64(y) 2886 case time.Duration: 2887 return time.Duration(x) * time.Duration(y) 2888 } 2889 case uint64: 2890 switch y := b.(type) { 2891 case uint: 2892 return int(x) * int(y) 2893 case uint8: 2894 return int(x) * int(y) 2895 case uint16: 2896 return int(x) * int(y) 2897 case uint32: 2898 return int(x) * int(y) 2899 case uint64: 2900 return int(x) * int(y) 2901 case int: 2902 return int(x) * int(y) 2903 case int8: 2904 return int(x) * int(y) 2905 case int16: 2906 return int(x) * int(y) 2907 case int32: 2908 return int(x) * int(y) 2909 case int64: 2910 return int(x) * int(y) 2911 case float32: 2912 return float64(x) * float64(y) 2913 case float64: 2914 return float64(x) * float64(y) 2915 case time.Duration: 2916 return time.Duration(x) * time.Duration(y) 2917 } 2918 case int: 2919 switch y := b.(type) { 2920 case uint: 2921 return int(x) * int(y) 2922 case uint8: 2923 return int(x) * int(y) 2924 case uint16: 2925 return int(x) * int(y) 2926 case uint32: 2927 return int(x) * int(y) 2928 case uint64: 2929 return int(x) * int(y) 2930 case int: 2931 return int(x) * int(y) 2932 case int8: 2933 return int(x) * int(y) 2934 case int16: 2935 return int(x) * int(y) 2936 case int32: 2937 return int(x) * int(y) 2938 case int64: 2939 return int(x) * int(y) 2940 case float32: 2941 return float64(x) * float64(y) 2942 case float64: 2943 return float64(x) * float64(y) 2944 case time.Duration: 2945 return time.Duration(x) * time.Duration(y) 2946 } 2947 case int8: 2948 switch y := b.(type) { 2949 case uint: 2950 return int(x) * int(y) 2951 case uint8: 2952 return int(x) * int(y) 2953 case uint16: 2954 return int(x) * int(y) 2955 case uint32: 2956 return int(x) * int(y) 2957 case uint64: 2958 return int(x) * int(y) 2959 case int: 2960 return int(x) * int(y) 2961 case int8: 2962 return int(x) * int(y) 2963 case int16: 2964 return int(x) * int(y) 2965 case int32: 2966 return int(x) * int(y) 2967 case int64: 2968 return int(x) * int(y) 2969 case float32: 2970 return float64(x) * float64(y) 2971 case float64: 2972 return float64(x) * float64(y) 2973 case time.Duration: 2974 return time.Duration(x) * time.Duration(y) 2975 } 2976 case int16: 2977 switch y := b.(type) { 2978 case uint: 2979 return int(x) * int(y) 2980 case uint8: 2981 return int(x) * int(y) 2982 case uint16: 2983 return int(x) * int(y) 2984 case uint32: 2985 return int(x) * int(y) 2986 case uint64: 2987 return int(x) * int(y) 2988 case int: 2989 return int(x) * int(y) 2990 case int8: 2991 return int(x) * int(y) 2992 case int16: 2993 return int(x) * int(y) 2994 case int32: 2995 return int(x) * int(y) 2996 case int64: 2997 return int(x) * int(y) 2998 case float32: 2999 return float64(x) * float64(y) 3000 case float64: 3001 return float64(x) * float64(y) 3002 case time.Duration: 3003 return time.Duration(x) * time.Duration(y) 3004 } 3005 case int32: 3006 switch y := b.(type) { 3007 case uint: 3008 return int(x) * int(y) 3009 case uint8: 3010 return int(x) * int(y) 3011 case uint16: 3012 return int(x) * int(y) 3013 case uint32: 3014 return int(x) * int(y) 3015 case uint64: 3016 return int(x) * int(y) 3017 case int: 3018 return int(x) * int(y) 3019 case int8: 3020 return int(x) * int(y) 3021 case int16: 3022 return int(x) * int(y) 3023 case int32: 3024 return int(x) * int(y) 3025 case int64: 3026 return int(x) * int(y) 3027 case float32: 3028 return float64(x) * float64(y) 3029 case float64: 3030 return float64(x) * float64(y) 3031 case time.Duration: 3032 return time.Duration(x) * time.Duration(y) 3033 } 3034 case int64: 3035 switch y := b.(type) { 3036 case uint: 3037 return int(x) * int(y) 3038 case uint8: 3039 return int(x) * int(y) 3040 case uint16: 3041 return int(x) * int(y) 3042 case uint32: 3043 return int(x) * int(y) 3044 case uint64: 3045 return int(x) * int(y) 3046 case int: 3047 return int(x) * int(y) 3048 case int8: 3049 return int(x) * int(y) 3050 case int16: 3051 return int(x) * int(y) 3052 case int32: 3053 return int(x) * int(y) 3054 case int64: 3055 return int(x) * int(y) 3056 case float32: 3057 return float64(x) * float64(y) 3058 case float64: 3059 return float64(x) * float64(y) 3060 case time.Duration: 3061 return time.Duration(x) * time.Duration(y) 3062 } 3063 case float32: 3064 switch y := b.(type) { 3065 case uint: 3066 return float64(x) * float64(y) 3067 case uint8: 3068 return float64(x) * float64(y) 3069 case uint16: 3070 return float64(x) * float64(y) 3071 case uint32: 3072 return float64(x) * float64(y) 3073 case uint64: 3074 return float64(x) * float64(y) 3075 case int: 3076 return float64(x) * float64(y) 3077 case int8: 3078 return float64(x) * float64(y) 3079 case int16: 3080 return float64(x) * float64(y) 3081 case int32: 3082 return float64(x) * float64(y) 3083 case int64: 3084 return float64(x) * float64(y) 3085 case float32: 3086 return float64(x) * float64(y) 3087 case float64: 3088 return float64(x) * float64(y) 3089 case time.Duration: 3090 return float64(x) * float64(y) 3091 } 3092 case float64: 3093 switch y := b.(type) { 3094 case uint: 3095 return float64(x) * float64(y) 3096 case uint8: 3097 return float64(x) * float64(y) 3098 case uint16: 3099 return float64(x) * float64(y) 3100 case uint32: 3101 return float64(x) * float64(y) 3102 case uint64: 3103 return float64(x) * float64(y) 3104 case int: 3105 return float64(x) * float64(y) 3106 case int8: 3107 return float64(x) * float64(y) 3108 case int16: 3109 return float64(x) * float64(y) 3110 case int32: 3111 return float64(x) * float64(y) 3112 case int64: 3113 return float64(x) * float64(y) 3114 case float32: 3115 return float64(x) * float64(y) 3116 case float64: 3117 return float64(x) * float64(y) 3118 case time.Duration: 3119 return float64(x) * float64(y) 3120 } 3121 case time.Duration: 3122 switch y := b.(type) { 3123 case uint: 3124 return time.Duration(x) * time.Duration(y) 3125 case uint8: 3126 return time.Duration(x) * time.Duration(y) 3127 case uint16: 3128 return time.Duration(x) * time.Duration(y) 3129 case uint32: 3130 return time.Duration(x) * time.Duration(y) 3131 case uint64: 3132 return time.Duration(x) * time.Duration(y) 3133 case int: 3134 return time.Duration(x) * time.Duration(y) 3135 case int8: 3136 return time.Duration(x) * time.Duration(y) 3137 case int16: 3138 return time.Duration(x) * time.Duration(y) 3139 case int32: 3140 return time.Duration(x) * time.Duration(y) 3141 case int64: 3142 return time.Duration(x) * time.Duration(y) 3143 case float32: 3144 return float64(x) * float64(y) 3145 case float64: 3146 return float64(x) * float64(y) 3147 case time.Duration: 3148 return time.Duration(x) * time.Duration(y) 3149 } 3150 } 3151 panic(fmt.Sprintf("invalid operation: %T * %T", a, b)) 3152 } 3153 3154 func Divide(a, b interface{}) float64 { 3155 switch x := a.(type) { 3156 case uint: 3157 switch y := b.(type) { 3158 case uint: 3159 return float64(x) / float64(y) 3160 case uint8: 3161 return float64(x) / float64(y) 3162 case uint16: 3163 return float64(x) / float64(y) 3164 case uint32: 3165 return float64(x) / float64(y) 3166 case uint64: 3167 return float64(x) / float64(y) 3168 case int: 3169 return float64(x) / float64(y) 3170 case int8: 3171 return float64(x) / float64(y) 3172 case int16: 3173 return float64(x) / float64(y) 3174 case int32: 3175 return float64(x) / float64(y) 3176 case int64: 3177 return float64(x) / float64(y) 3178 case float32: 3179 return float64(x) / float64(y) 3180 case float64: 3181 return float64(x) / float64(y) 3182 } 3183 case uint8: 3184 switch y := b.(type) { 3185 case uint: 3186 return float64(x) / float64(y) 3187 case uint8: 3188 return float64(x) / float64(y) 3189 case uint16: 3190 return float64(x) / float64(y) 3191 case uint32: 3192 return float64(x) / float64(y) 3193 case uint64: 3194 return float64(x) / float64(y) 3195 case int: 3196 return float64(x) / float64(y) 3197 case int8: 3198 return float64(x) / float64(y) 3199 case int16: 3200 return float64(x) / float64(y) 3201 case int32: 3202 return float64(x) / float64(y) 3203 case int64: 3204 return float64(x) / float64(y) 3205 case float32: 3206 return float64(x) / float64(y) 3207 case float64: 3208 return float64(x) / float64(y) 3209 } 3210 case uint16: 3211 switch y := b.(type) { 3212 case uint: 3213 return float64(x) / float64(y) 3214 case uint8: 3215 return float64(x) / float64(y) 3216 case uint16: 3217 return float64(x) / float64(y) 3218 case uint32: 3219 return float64(x) / float64(y) 3220 case uint64: 3221 return float64(x) / float64(y) 3222 case int: 3223 return float64(x) / float64(y) 3224 case int8: 3225 return float64(x) / float64(y) 3226 case int16: 3227 return float64(x) / float64(y) 3228 case int32: 3229 return float64(x) / float64(y) 3230 case int64: 3231 return float64(x) / float64(y) 3232 case float32: 3233 return float64(x) / float64(y) 3234 case float64: 3235 return float64(x) / float64(y) 3236 } 3237 case uint32: 3238 switch y := b.(type) { 3239 case uint: 3240 return float64(x) / float64(y) 3241 case uint8: 3242 return float64(x) / float64(y) 3243 case uint16: 3244 return float64(x) / float64(y) 3245 case uint32: 3246 return float64(x) / float64(y) 3247 case uint64: 3248 return float64(x) / float64(y) 3249 case int: 3250 return float64(x) / float64(y) 3251 case int8: 3252 return float64(x) / float64(y) 3253 case int16: 3254 return float64(x) / float64(y) 3255 case int32: 3256 return float64(x) / float64(y) 3257 case int64: 3258 return float64(x) / float64(y) 3259 case float32: 3260 return float64(x) / float64(y) 3261 case float64: 3262 return float64(x) / float64(y) 3263 } 3264 case uint64: 3265 switch y := b.(type) { 3266 case uint: 3267 return float64(x) / float64(y) 3268 case uint8: 3269 return float64(x) / float64(y) 3270 case uint16: 3271 return float64(x) / float64(y) 3272 case uint32: 3273 return float64(x) / float64(y) 3274 case uint64: 3275 return float64(x) / float64(y) 3276 case int: 3277 return float64(x) / float64(y) 3278 case int8: 3279 return float64(x) / float64(y) 3280 case int16: 3281 return float64(x) / float64(y) 3282 case int32: 3283 return float64(x) / float64(y) 3284 case int64: 3285 return float64(x) / float64(y) 3286 case float32: 3287 return float64(x) / float64(y) 3288 case float64: 3289 return float64(x) / float64(y) 3290 } 3291 case int: 3292 switch y := b.(type) { 3293 case uint: 3294 return float64(x) / float64(y) 3295 case uint8: 3296 return float64(x) / float64(y) 3297 case uint16: 3298 return float64(x) / float64(y) 3299 case uint32: 3300 return float64(x) / float64(y) 3301 case uint64: 3302 return float64(x) / float64(y) 3303 case int: 3304 return float64(x) / float64(y) 3305 case int8: 3306 return float64(x) / float64(y) 3307 case int16: 3308 return float64(x) / float64(y) 3309 case int32: 3310 return float64(x) / float64(y) 3311 case int64: 3312 return float64(x) / float64(y) 3313 case float32: 3314 return float64(x) / float64(y) 3315 case float64: 3316 return float64(x) / float64(y) 3317 } 3318 case int8: 3319 switch y := b.(type) { 3320 case uint: 3321 return float64(x) / float64(y) 3322 case uint8: 3323 return float64(x) / float64(y) 3324 case uint16: 3325 return float64(x) / float64(y) 3326 case uint32: 3327 return float64(x) / float64(y) 3328 case uint64: 3329 return float64(x) / float64(y) 3330 case int: 3331 return float64(x) / float64(y) 3332 case int8: 3333 return float64(x) / float64(y) 3334 case int16: 3335 return float64(x) / float64(y) 3336 case int32: 3337 return float64(x) / float64(y) 3338 case int64: 3339 return float64(x) / float64(y) 3340 case float32: 3341 return float64(x) / float64(y) 3342 case float64: 3343 return float64(x) / float64(y) 3344 } 3345 case int16: 3346 switch y := b.(type) { 3347 case uint: 3348 return float64(x) / float64(y) 3349 case uint8: 3350 return float64(x) / float64(y) 3351 case uint16: 3352 return float64(x) / float64(y) 3353 case uint32: 3354 return float64(x) / float64(y) 3355 case uint64: 3356 return float64(x) / float64(y) 3357 case int: 3358 return float64(x) / float64(y) 3359 case int8: 3360 return float64(x) / float64(y) 3361 case int16: 3362 return float64(x) / float64(y) 3363 case int32: 3364 return float64(x) / float64(y) 3365 case int64: 3366 return float64(x) / float64(y) 3367 case float32: 3368 return float64(x) / float64(y) 3369 case float64: 3370 return float64(x) / float64(y) 3371 } 3372 case int32: 3373 switch y := b.(type) { 3374 case uint: 3375 return float64(x) / float64(y) 3376 case uint8: 3377 return float64(x) / float64(y) 3378 case uint16: 3379 return float64(x) / float64(y) 3380 case uint32: 3381 return float64(x) / float64(y) 3382 case uint64: 3383 return float64(x) / float64(y) 3384 case int: 3385 return float64(x) / float64(y) 3386 case int8: 3387 return float64(x) / float64(y) 3388 case int16: 3389 return float64(x) / float64(y) 3390 case int32: 3391 return float64(x) / float64(y) 3392 case int64: 3393 return float64(x) / float64(y) 3394 case float32: 3395 return float64(x) / float64(y) 3396 case float64: 3397 return float64(x) / float64(y) 3398 } 3399 case int64: 3400 switch y := b.(type) { 3401 case uint: 3402 return float64(x) / float64(y) 3403 case uint8: 3404 return float64(x) / float64(y) 3405 case uint16: 3406 return float64(x) / float64(y) 3407 case uint32: 3408 return float64(x) / float64(y) 3409 case uint64: 3410 return float64(x) / float64(y) 3411 case int: 3412 return float64(x) / float64(y) 3413 case int8: 3414 return float64(x) / float64(y) 3415 case int16: 3416 return float64(x) / float64(y) 3417 case int32: 3418 return float64(x) / float64(y) 3419 case int64: 3420 return float64(x) / float64(y) 3421 case float32: 3422 return float64(x) / float64(y) 3423 case float64: 3424 return float64(x) / float64(y) 3425 } 3426 case float32: 3427 switch y := b.(type) { 3428 case uint: 3429 return float64(x) / float64(y) 3430 case uint8: 3431 return float64(x) / float64(y) 3432 case uint16: 3433 return float64(x) / float64(y) 3434 case uint32: 3435 return float64(x) / float64(y) 3436 case uint64: 3437 return float64(x) / float64(y) 3438 case int: 3439 return float64(x) / float64(y) 3440 case int8: 3441 return float64(x) / float64(y) 3442 case int16: 3443 return float64(x) / float64(y) 3444 case int32: 3445 return float64(x) / float64(y) 3446 case int64: 3447 return float64(x) / float64(y) 3448 case float32: 3449 return float64(x) / float64(y) 3450 case float64: 3451 return float64(x) / float64(y) 3452 } 3453 case float64: 3454 switch y := b.(type) { 3455 case uint: 3456 return float64(x) / float64(y) 3457 case uint8: 3458 return float64(x) / float64(y) 3459 case uint16: 3460 return float64(x) / float64(y) 3461 case uint32: 3462 return float64(x) / float64(y) 3463 case uint64: 3464 return float64(x) / float64(y) 3465 case int: 3466 return float64(x) / float64(y) 3467 case int8: 3468 return float64(x) / float64(y) 3469 case int16: 3470 return float64(x) / float64(y) 3471 case int32: 3472 return float64(x) / float64(y) 3473 case int64: 3474 return float64(x) / float64(y) 3475 case float32: 3476 return float64(x) / float64(y) 3477 case float64: 3478 return float64(x) / float64(y) 3479 } 3480 } 3481 panic(fmt.Sprintf("invalid operation: %T / %T", a, b)) 3482 } 3483 3484 func Modulo(a, b interface{}) int { 3485 switch x := a.(type) { 3486 case uint: 3487 switch y := b.(type) { 3488 case uint: 3489 return int(x) % int(y) 3490 case uint8: 3491 return int(x) % int(y) 3492 case uint16: 3493 return int(x) % int(y) 3494 case uint32: 3495 return int(x) % int(y) 3496 case uint64: 3497 return int(x) % int(y) 3498 case int: 3499 return int(x) % int(y) 3500 case int8: 3501 return int(x) % int(y) 3502 case int16: 3503 return int(x) % int(y) 3504 case int32: 3505 return int(x) % int(y) 3506 case int64: 3507 return int(x) % int(y) 3508 } 3509 case uint8: 3510 switch y := b.(type) { 3511 case uint: 3512 return int(x) % int(y) 3513 case uint8: 3514 return int(x) % int(y) 3515 case uint16: 3516 return int(x) % int(y) 3517 case uint32: 3518 return int(x) % int(y) 3519 case uint64: 3520 return int(x) % int(y) 3521 case int: 3522 return int(x) % int(y) 3523 case int8: 3524 return int(x) % int(y) 3525 case int16: 3526 return int(x) % int(y) 3527 case int32: 3528 return int(x) % int(y) 3529 case int64: 3530 return int(x) % int(y) 3531 } 3532 case uint16: 3533 switch y := b.(type) { 3534 case uint: 3535 return int(x) % int(y) 3536 case uint8: 3537 return int(x) % int(y) 3538 case uint16: 3539 return int(x) % int(y) 3540 case uint32: 3541 return int(x) % int(y) 3542 case uint64: 3543 return int(x) % int(y) 3544 case int: 3545 return int(x) % int(y) 3546 case int8: 3547 return int(x) % int(y) 3548 case int16: 3549 return int(x) % int(y) 3550 case int32: 3551 return int(x) % int(y) 3552 case int64: 3553 return int(x) % int(y) 3554 } 3555 case uint32: 3556 switch y := b.(type) { 3557 case uint: 3558 return int(x) % int(y) 3559 case uint8: 3560 return int(x) % int(y) 3561 case uint16: 3562 return int(x) % int(y) 3563 case uint32: 3564 return int(x) % int(y) 3565 case uint64: 3566 return int(x) % int(y) 3567 case int: 3568 return int(x) % int(y) 3569 case int8: 3570 return int(x) % int(y) 3571 case int16: 3572 return int(x) % int(y) 3573 case int32: 3574 return int(x) % int(y) 3575 case int64: 3576 return int(x) % int(y) 3577 } 3578 case uint64: 3579 switch y := b.(type) { 3580 case uint: 3581 return int(x) % int(y) 3582 case uint8: 3583 return int(x) % int(y) 3584 case uint16: 3585 return int(x) % int(y) 3586 case uint32: 3587 return int(x) % int(y) 3588 case uint64: 3589 return int(x) % int(y) 3590 case int: 3591 return int(x) % int(y) 3592 case int8: 3593 return int(x) % int(y) 3594 case int16: 3595 return int(x) % int(y) 3596 case int32: 3597 return int(x) % int(y) 3598 case int64: 3599 return int(x) % int(y) 3600 } 3601 case int: 3602 switch y := b.(type) { 3603 case uint: 3604 return int(x) % int(y) 3605 case uint8: 3606 return int(x) % int(y) 3607 case uint16: 3608 return int(x) % int(y) 3609 case uint32: 3610 return int(x) % int(y) 3611 case uint64: 3612 return int(x) % int(y) 3613 case int: 3614 return int(x) % int(y) 3615 case int8: 3616 return int(x) % int(y) 3617 case int16: 3618 return int(x) % int(y) 3619 case int32: 3620 return int(x) % int(y) 3621 case int64: 3622 return int(x) % int(y) 3623 } 3624 case int8: 3625 switch y := b.(type) { 3626 case uint: 3627 return int(x) % int(y) 3628 case uint8: 3629 return int(x) % int(y) 3630 case uint16: 3631 return int(x) % int(y) 3632 case uint32: 3633 return int(x) % int(y) 3634 case uint64: 3635 return int(x) % int(y) 3636 case int: 3637 return int(x) % int(y) 3638 case int8: 3639 return int(x) % int(y) 3640 case int16: 3641 return int(x) % int(y) 3642 case int32: 3643 return int(x) % int(y) 3644 case int64: 3645 return int(x) % int(y) 3646 } 3647 case int16: 3648 switch y := b.(type) { 3649 case uint: 3650 return int(x) % int(y) 3651 case uint8: 3652 return int(x) % int(y) 3653 case uint16: 3654 return int(x) % int(y) 3655 case uint32: 3656 return int(x) % int(y) 3657 case uint64: 3658 return int(x) % int(y) 3659 case int: 3660 return int(x) % int(y) 3661 case int8: 3662 return int(x) % int(y) 3663 case int16: 3664 return int(x) % int(y) 3665 case int32: 3666 return int(x) % int(y) 3667 case int64: 3668 return int(x) % int(y) 3669 } 3670 case int32: 3671 switch y := b.(type) { 3672 case uint: 3673 return int(x) % int(y) 3674 case uint8: 3675 return int(x) % int(y) 3676 case uint16: 3677 return int(x) % int(y) 3678 case uint32: 3679 return int(x) % int(y) 3680 case uint64: 3681 return int(x) % int(y) 3682 case int: 3683 return int(x) % int(y) 3684 case int8: 3685 return int(x) % int(y) 3686 case int16: 3687 return int(x) % int(y) 3688 case int32: 3689 return int(x) % int(y) 3690 case int64: 3691 return int(x) % int(y) 3692 } 3693 case int64: 3694 switch y := b.(type) { 3695 case uint: 3696 return int(x) % int(y) 3697 case uint8: 3698 return int(x) % int(y) 3699 case uint16: 3700 return int(x) % int(y) 3701 case uint32: 3702 return int(x) % int(y) 3703 case uint64: 3704 return int(x) % int(y) 3705 case int: 3706 return int(x) % int(y) 3707 case int8: 3708 return int(x) % int(y) 3709 case int16: 3710 return int(x) % int(y) 3711 case int32: 3712 return int(x) % int(y) 3713 case int64: 3714 return int(x) % int(y) 3715 } 3716 } 3717 panic(fmt.Sprintf("invalid operation: %T %% %T", a, b)) 3718 }